473,465 Members | 1,373 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Detecting which context menu item was selected

I have a TEXTAREA element. A user right clicks within in to get the
context menu and they select "paste". I want my javascript code to
know that they selected "paste".
I know you can capture the mouse click, but can we capture exactly what
event that attempted?

Thanks,
Mike

Jun 29 '06 #1
3 3851
br*****@gmail.com said the following on 6/29/2006 4:54 PM:
I have a TEXTAREA element. A user right clicks within in to get the
context menu and they select "paste".
OK, but that is not the only way to "paste". There are at least 3 other
ways.
I want my javascript code to know that they selected "paste".
Do you want to know they selected "paste" from that menu or that they
pasted text into your textarea? The difference in the two is astronomical.
I know you can capture the mouse click, but can we capture exactly what
event that attempted?


Doubtful, depending on what you are really trying to do.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Temporarily at: http://members.aol.com/_ht_a/hikksnotathome/cljfaq/
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jun 29 '06 #2
Ultimately, I'm trying to keep a running total of how many characters
are in the TEXTAREA. So really, however text can be entered, whether
it's keyed or pasted (context menu, control+v), I want to be able to
get the total.
Randy Webb wrote:
br*****@gmail.com said the following on 6/29/2006 4:54 PM:
I have a TEXTAREA element. A user right clicks within in to get the
context menu and they select "paste".


OK, but that is not the only way to "paste". There are at least 3 other
ways.
I want my javascript code to know that they selected "paste".


Do you want to know they selected "paste" from that menu or that they
pasted text into your textarea? The difference in the two is astronomical.
I know you can capture the mouse click, but can we capture exactly what
event that attempted?


Doubtful, depending on what you are really trying to do.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Temporarily at: http://members.aol.com/_ht_a/hikksnotathome/cljfaq/
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/


Jun 29 '06 #3
br*****@gmail.com wrote:
I have a TEXTAREA element. A user right clicks within in to get the
context menu and they select "paste". I want my javascript code to
know that they selected "paste".
I know you can capture the mouse click, but can we capture exactly what
event that attempted?
I 'ld say you should use as much event handlers as possible then. The
following could be a start (but not complete!):

<script type="text/javascript">
function updateBox(nr) {
document.forms[0].howmany.value = nr
}
</script>
<form method="get">
<textarea name="txt" cols="30" rows="5"
onclick="updateBox(this.value.length)"
ondblclick="updateBox(this.value.length)"
onmousedown="updateBox(this.value.length)"
onmouseup="updateBox(this.value.length)"
onmouseover="updateBox(this.value.length)"
onmousemove="updateBox(this.value.length)"
onmouseout="updateBox(this.value.length)"
onkeypress="updateBox(this.value.length)"
onkeydown="updateBox(this.value.length)"
onkeyup="updateBox(this.value.length)"
onfocus="updateBox(this.value.length)"
onblur="updateBox(this.value.length)"
onselect="updateBox(this.value.length)"
onchange="updateBox(this.value.length)"

</textarea><br>
Length:
<input type="text" size="4" name="howmany" value="0">
</form>

Further handlers:

http://www.w3.org/TR/DOM-Level-2-Events/events.html
http://msdn.microsoft.com/workshop/a...nce/events.asp
http://developer.mozilla.org/en/docs...Event_Handlers

I would just put them all in the code. Brute force, you know :-)

--
Bart

Jun 30 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Mohit Gupta | last post by:
Hi all, Lately I have been working on an application in VB .net CF for Pocket PC device. I have a small question about Context Menu. When I try to close the window after context menu is poped...
5
by: yxq | last post by:
Hi I am build vb6 Context menu extension, but how to determine which popup menu item(popupItem1 and popupItem2) was clicked? Thanks The code ' ' IContextMenu::QueryContextMenu '
4
by: Don Peters | last post by:
I can't seem to find an answer to this problem in spite of many searches. I have a VB.NET program that has a context menu popup event. In it I associate some menu items with their events, as...
8
by: Sameh Ahmed | last post by:
Hello there i have a context menu linmked to a listview control. I want the context mnu to appear ONLY when i right click on an item and not any place in listview. any ideas? Thanks in advance....
5
by: lgbjr | last post by:
Hello All, I have several Pictureboxes (linked to an AccessDB) on a VB.NET form. I would like to use a context menu to allow the user to open the picture in their default picture viewer or...
2
by: gilad | last post by:
Hi, I seem to be having a problem getting a context menu to work in Explorer. The menu item installs fine, but when I click it a message box should pop up indicating the command was received and...
2
by: travelrats | last post by:
Hi Here's my problem - I've been trying to figure this out for a while and ran out of ideas... <div> id1 contains <div> id2 (a geographical map) <div> id2 contains a context menu made out of...
4
by: Karl | last post by:
Hi all, I want to write an application that is launched from the context menu in Windows Explorer/Computer. That is to say, when I am browsing around my hard drive and get to any location I...
0
by: EvilProject | last post by:
Hi im writing a class of a context menu where each menu item is linked to a Tree Node. I have a click event (that belongs to the context menu class ,not the menu item class) that it's event...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.